/**
 * 
 */
package org.mips.Sirius.ui;

import java.util.ArrayList;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;

/**
 * @author mips
 * 
 */
public class SiriusLoadingDialog extends ProgressDialog {

	ArrayList<String> expectedTokens;

	/**
	 * @param context
	 */
	public SiriusLoadingDialog(Context context, ArrayList<String> tokens) {
		super(context);
		this.expectedTokens = tokens;
	}

	public SiriusLoadingDialog(Context context) {
		this(context, new ArrayList<String>());
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

		this.setIndeterminate(true);
		this.setMessage("Loading");
	}

	public void notifyReady(String token) {
		if (this.expectedTokens.contains(token)) {
			this.expectedTokens.remove(token);
		}
		if (this.expectedTokens.isEmpty()) {
			this.dismiss();
		}
	}
}
